#region Using directives
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;
#endregion

namespace SharpWind.Resources.Managers
{
	public abstract class ResourceManager<T> where T : Resource
	{
		#region Fields

		private Dictionary<string, T> resources = new Dictionary<string, T>();

		#endregion

		#region Methods

		public void Add( string name, T resource )
		{
			if( !string.IsNullOrEmpty( name ) && !this.resources.ContainsKey( name ) )
			{
				this.resources.Add( name, resource );
			}
		}

		internal void LoadContent( ContentManager contentManager )
		{
			foreach( T resource in this.resources.Values )
			{
				resource.LoadContent( contentManager );
			}
		}

		#endregion

		#region Properties

		public T this[string name]
		{
			get
			{
				if( !string.IsNullOrEmpty( name ) && this.resources.ContainsKey( name ) )
				{
					return this.resources[name];
				}
				else
				{
					return null;
				}
			}
		}

		public int Count
		{
			get
			{
				return this.resources.Count;
			}
		}

		#endregion
	}
}
